﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inspired.Euler
{
    /// <summary>
    /// A Pythagorean triplet is a set of three natural numbers, a  b  c, for which,
    /// 
    /// a² + b² = c²
    /// 
    /// For example, 3² + 4² = 9 + 16 = 25 = 5².
    /// 
    /// There exists exactly one Pythagorean triplet for which a + b + c = 1000.
    /// Find the product abc.
    /// </summary>
    public static class Problem009
    {
        /// <summary>
        /// Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000.
        /// </summary>
        [EulerProblem(9, Title = "Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000.")]
        public static long Solve()
        {
            for (double a = 1; a < 1000; a++)
            {
                for (double b = 1; b < 1000; b++)
                {
                    double c = Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2));
                    if ((a + b + c) == 1000)
                    {
                        return (long)(a * b * c);
                    }
                }
            }
            return -1;
        }
    }
}
